package com.bytedance.common.utility;

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPOutputStream;

public abstract class e {
    public static final class a {
        public boolean a;

        public a() {

        }
    }

    private static e a;

    static {
        a = new bb();
    }

    public e() {

    }

    public static e a() {
        return e.a;
    }

    public static void a(e arg1) {
        if(arg1 != e.a) {
            e.a = arg1;
        }
    }

    private static byte[] a(byte[] arg3) throws Exception {
        GZIPOutputStream v2;
        ByteArrayOutputStream v0_1;
        GZIPOutputStream v1 = null;
        try {
            v0_1 = new ByteArrayOutputStream(8192);
            v2 = new GZIPOutputStream(((OutputStream)v0_1));
            v2.write(arg3);
            v2.close();
            return v0_1.toByteArray();
        } catch(Throwable v0) {
        }finally {
            if(v1 != null) {
                v1.close();
            }
        }
        return null;
    }

    public final String a(String arg3) throws Exception {
        a v0 = new a();
        v0.a = true;
        return this.a(arg3, null, v0);
    }

    public abstract String a(String arg1, Map arg2, a arg3) throws Exception;

    public abstract String a(String arg1, List arg2, Map arg3, a arg4) throws CommonHttpException;

    public abstract String a(String arg1, byte[] arg2, Map arg3, a arg4) throws CommonHttpException;

    public final String a(String arg4, byte[] arg5, boolean arg6, String arg7, boolean arg8) throws CommonHttpException {
        HashMap v0 = new HashMap();
        if(arg6) {
            try {
                arg5 = e.a(arg5);
                ((Map)v0).put("Content-Encoding", "gzip");
            }
            catch(Exception v0_1) {
                throw new CommonHttpException(0, v0_1.getMessage());
            }
        }

        if(!android.support.design.a.isTextEmpty(arg7)) {
            ((Map)v0).put("Content-Type", arg7);
        }

        a v1 = new a();
        v1.a = arg8;
        return this.a(arg4, arg5, ((Map)v0), v1);
    }
}

